<div id="content">
    <h3><a href="?p=home&t=student">Geoplaza</a><a href="?p=home&t=student"> &rsaquo;&rsaquo; studenten</a> &rsaquo;&rsaquo; Mijn profiel</h3>
    <div id="Profilehead">Profiel</div>

    <div id="profile">
        <?php
        require_once(CONFIG_PATH.'appvars.php');
        require_once(CONFIG_PATH.'config.php');

        // Make sure the user is logged in before going any further.
        if (!isset($_SESSION['user_id'])) {
            echo '<p>Please <a href="?p=home&t=student">log in</a> to access this page.</p>';
            exit();
        }

        // Connect to the database
        $dbc = mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_DATABASE);

        // Grab the profile data from the database
        if (!isset($_GET['user_id'])) {
            $query = "SELECT voornaam, achternaam, geslacht, geboortedatum, adres, postcode, woonplaats, provencie, telefoon, biography, foto, opleiding, niveau, school, stagedate, email FROM studentprofiel WHERE studentID = '" . $_SESSION['user_id'] . "'";
        } else {
            $query = "SELECT voornaam, achternaam, geslacht, geboortedatum, adres, postcode, woonplaats, provencie, telefoon, biography, foto, opleiding, niveau, school, stagedate, email FROM studentprofiel WHERE studentID = '" . $_GET['user_id'] . "'";
        }
        $data = mysqli_query($dbc, $query);

        if (mysqli_num_rows($data) == 1) {
            // The user row was found so display the user data
            $row = mysqli_fetch_array($data);

            if (!empty($row['foto'])) {
                echo '<img class="profile" src="' . MM_UPLOADPATH . $row['foto'] . '" alt="Profile Picture" />';
            }
            if (!empty($row['voornaam'])) {
                echo '<div id="Profilecontent">' . $row['voornaam'] . ' ' . $row['achternaam'] . '';
                echo '<p>' . $row['biography'] . '</p></div>';
            }
            echo '<fieldset class="info">
            <legend>Persoonlijke informatie</legend> ';
            echo '<p class="titel">Voornaam:</p><p class="in">' . $row['voornaam'] . '</p>';
            echo '<p class="titel">Achternaam:</p><p class="in">' . $row['achternaam'] . '</p>';
            echo '<p class="titel">Geboortedatum:</p><p class="in">' . $row['geboortedatum'] . '</p>';
            echo '<p class="titel">Geslacht:</p><p class="in">' . $row['geslacht'] . '</p>';
            echo '<p class="titel">Adres:</p><p class="in">' . $row['adres'] . '</p>';
            echo '<p class="titel">&nbsp; </p><p class="in">' . $row['postcode'] . '   ' . $row['woonplaats'] . '</p>';
            echo '<p class="titel">Provencie:</p><p class="in">' . $row['provencie'] . '</p>';
            echo '<p class="titel">Telefoon:</p><p class="in">0' . $row['telefoon'] . '</p>';
            echo '<p class="titel">Email:</p><p class="in">' . $row['email'] . '</p>';
            echo '<p class="titel">Opleiding:</p><p class="in">' . $row['opleiding'] . ' in ' . $row['school'] . '</p>';
            echo '<p class="titel">Niveau:</p><p class="in">' . $row['niveau'] . '</p>';
            echo '<p class="titel">Datum voor de stage:</p><p class="in">' . $row['stagedate'] . '</p>';
            echo '</fieldset>';
        } // End of check for a single row of user results
        else {
            echo '<p class="error">There was a problem accessing your profile.</p>';
        }
        mysqli_close($dbc);
        ?>

    </div>
</div>